<?php
/**
*
* @package - Allytools Mod
* @version $Id: allytool.php 1 2010-01-24 08:49:05Z allytools $
* @copyright (c) Pionier ( http://board.allytool.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License 
*
*/

/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : '../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
$allytool_root_path = ALLYTOOL_ROOT_PATH;
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . $allytool_root_path . 'includes/functions_allytool.' . $phpEx);
include_once($phpbb_root_path . 'includes/message_parser.' . $phpEx);
if (!function_exists('group_memberships'))
                  {
                     include($phpbb_root_path . "includes/functions_user.$phpEx");
                  }

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('mods/lang_allytool');

// Get formel config
$allytool_config 		= get_allytool_config();
$allytool_group_id 		= array($allytool_config['restrict_to']);
$allytool_tool_on 		= $allytool_config['tool_on'];

/*
// zu überprüfender User ( Beispiel: Der User, der diese Seite aufgerufen hat )
$benutzer_id = $user->data['user_id'];
*/
// Nun erfolgt die eigentliche Prüfung:
$is_in_group = group_memberships($allytool_group_id, $user->data['user_id'] , true);

// Fals nicht Abgeschaltet
if ( $allytool_tool_on == 0 )
{
	$auth_msg = sprintf($user->lang['ALLYTOOL_DISABLE'],  '<a href="' . $phpbb_root_path . 'index.' .$phpEx.'" class="gen">', '</a>');
	trigger_error($auth_msg);
}

// Fals nicht berechtigt -> Fehlermeldung
if ($is_in_group != true)
{
	$auth_msg = sprintf($user->lang['ALLYTOOL_DENIED'], '<a href="' . $phpbb_root_path . 'ucp.' .$phpEx,'?i=groups'.'" class="gen">', '</a>', '<a href="' . $phpbb_root_path . 'index.' .$phpEx.'" class="gen">', '</a>');
	trigger_error($auth_msg);
}

// Start Updatechek
if ( is_dir( $phpbb_root_path . 'install_allytool/' ) === TRUE )
{
	if ( is_file( $phpbb_root_path . 'install_allytool/install.'.$phpEx ) === TRUE )
	{
		include $phpbb_root_path . 'install_allytool/install.'.$phpEx;

		if ( version_compare( $current_version, $allytool_config['allytool_version'], '<=' ) === TRUE )
		{
			$template->assign_vars(array(
				'S_DISPLAY_GENERAL'	=> true,
				'GEN_TITLE'				=> $user->lang['ALLYTOOL_ERROR'],
				'GEN_MESSAGE'			=> sprintf( $user->lang['ALLYTOOL_DELETE_DIR'], $phpbb_root_path . 'install_allytool' )
			));
		}
		else
		{
			$template->assign_vars(array(
				'S_DISPLAY_GENERAL'	=> true,
				'GEN_TITLE'				=> $user->lang['ALLYTOOL_UPDATE'],
				'GEN_MESSAGE'			=> sprintf( $user->lang['ALLYTOOL_UPDATE_TEXT'], $phpbb_root_path . 'install_allytool/install.'.$phpEx, $current_version )
			));
		}

		$load_center = false;
	}
} 

// Daten für Footer
		$template->assign_vars(array(
			'ALLYTOOL_MOD_RELEASE' => sprintf($user->lang['ALLYTOOL_COPY'], $allytool_config['allytool_version'])
		));

//Navi

/*
* init and get various values
*/
$view		= request_var('view', '');


if ($view)
{
	switch ($view)
	{
		case 'planet':
			
				include($phpbb_root_path . $allytool_root_path . 'block/planet.' . $phpEx); 
			
	    break;
		case 'ally':
		    $template->assign_vars(array(
	            'S_DISPLAY_ALLY'	=> true,
	        ));
		break;
		case 'gala':
		    $template->assign_vars(array(
	            'S_DISPLAY_GALA'	=> true,
	        ));
		break;
		case 'gala':
		    $template->assign_vars(array(
	            'S_DISPLAY_GALA'	=> true,
	        ));
		break;
		case 'player':
		    $template->assign_vars(array(
	            'S_DISPLAY_PLAYER'	=> true,
	        ));
		break;
		case 'fleet':
		    $template->assign_vars(array(
	            'S_DISPLAY_FLEET'	=> true,
	        ));
		break;
		case 'lab':
		    $template->assign_vars(array(
	            'S_DISPLAY_LAB'	=> true,
	        ));
		break;
		case 'building':
		    $template->assign_vars(array(
	            'S_DISPLAY_BUILDING'	=> true,
	        ));
		break;
		case 'stats_a':
		    $template->assign_vars(array(
	            'S_DISPLAY_STATS_A'	=> true,
	        ));
		break;
		case 'point':
		    $template->assign_vars(array(
	            'S_DISPLAY_POINT'	=> true,
	        ));
		break;
		case 'imp':
		    $template->assign_vars(array(
	            'S_DISPLAY_IMP'	=> true,
	        ));
		break;
		case 'own_planet':
		    $template->assign_vars(array(
	            'S_DISPLAY_OWN_PLANET'	=> true,
	        ));
		break;
		case 'own_fleet':
		    $template->assign_vars(array(
	            'S_DISPLAY_OWN_FLEET'	=> true,
	        ));
		break;
		case 'own_lab':
		    $template->assign_vars(array(
	            'S_DISPLAY_OWN_LAB'	=> true,
	        ));
		break;
		case 'settings':
		    $template->assign_vars(array(
	            'S_DISPLAY_SETTINGS'	=> true,
	        ));
		break;
		case 'ffl':
		    $template->assign_vars(array(
	            'S_DISPLAY_FFL'	=> true,
	        ));
		break;
		case 'm_m_st':
		    $template->assign_vars(array(
	            'S_DISPLAY_M_M_ST'	=> true,
	        ));
		break;
		case 'm_tf_st':
		    $template->assign_vars(array(
	            'S_DISPLAY_M_TF_ST'	=> true,
	        ));
		break;
		case 'rack_sim':
		    $template->assign_vars(array(
	            'S_DISPLAY_RACK_SIM'	=> true,
	        ));
		break;
		case 'rack_plan':
		    $template->assign_vars(array(
	            'S_DISPLAY_RACK_PLAN'	=> true,
	        ));
		break;
	    };
}
	
// output page
page_header($user->lang['ALLYTOOL']);

$template->set_filenames(array(
	'body' => '/allytool/allytool_body.html'));

page_footer();



?>